package com.hb.core.pojo.project.order.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hb.core.pojo.Attachments;
import com.hb.core.pojo.JSONObjectProperty;
import com.hb.core.pojo.parent.MPCommonEntity;
import com.hb.core.pojo.project.order.dto.UserRefundDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.fzzn.core.model.enums.AuditStatusEnum;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 订单信息
 *
 * @author zhongdl
 * @since 2021-09-30
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("trade_user_order")
@ApiModel(value = "订单信息对象", description = "订单信息")
public class UserOrder extends MPCommonEntity {

    @ApiModelProperty(value = "用户表主键(au_user)")
    private Long userId;

    /**
     * 冗余该条数据所属用户所在企业的名称
     */
    @ApiModelProperty(value = "单位名称")
    private String orgName;

    @ApiModelProperty(value = "订单号")
    private String outOrderNo;

    @ApiModelProperty(value = "第三方平台交易订单号, 支付成功时更新")
    private String tradeNo;

    @ApiModelProperty(value = "订单金额")
    private BigDecimal orderAmount;

    @ApiModelProperty(value = "实际付款金额")
    private BigDecimal actualAmount;

    /**
     * 订单支付状态
     * PAY_SUCCESS(1, "支付成功"),
     * UN_PAY(2, "待支付"),
     * PAY_FAIL(3, "支付失败"),
     * SAVED(4, "已保存");
     *
     * @see com.hb.core.pojo.enums.PayStatusEnum
     */
    @ApiModelProperty(value = "订单支付状态 - 1: 支付成功(待审核), 2: 待支付, 3: 支付失败 4: 已保存 5: 已退款")
    private Integer orderStatus;

    /**
     * 订单的审核状态仅针对于线下付款的数据, 上传付款凭证之后由系统指定用户审核
     * 对于对接了支付宝, 微信等第三方的支付数据, 该字段没有意义
     * SAVED(0, "已保存"),
     * PASSED(1, "审核通过"),
     * WAITING(2, "审核中"),
     * REJECTED(3, "已驳回");
     *
     * @see AuditStatusEnum
     */
    @ApiModelProperty(value = "订单审核状态")
    private Integer auditStatus;

    @ApiModelProperty(value = "审核状态为不通过时需填写原因")
    private String reason;

    @ApiModelProperty(value = "支付类型 - 1: 支付宝, 2: 微信, 3: 银联")
    private Integer payType;

    @ApiModelProperty(value = "支付账号")
    private String payAccount;

    @ApiModelProperty(value = "支付时间")
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime  payTime;

    @ApiModelProperty(value = "联系人名称")
    private String contactName;

    @ApiModelProperty(value = "联系人手机")
    private String mobile;

    @ApiModelProperty(value = "联系人邮箱")
    private String email;

    @ApiModelProperty(value = "固定电话")
    private String tel;

    @ApiModelProperty(value = "是否邮寄")
    private Integer mailFlag;

    @ApiModelProperty(value = "收件人名称")
    private String addresseeName;

    @ApiModelProperty(value = "收件人联系方式")
    private String contactInformation;

    @ApiModelProperty(value = "邮政编码")
    private String postalCode;

    @ApiModelProperty(value = "邮寄地址")
    private String mailAddress;

    @ApiModelProperty(value = "订单附件, 目前用于线下缴费的付款凭证")
    private Attachments attachment;

    /**
     * @see UserRefundDTO
     */
    @ApiModelProperty(value = "发生退款时的退款方信息")
    private JSONObjectProperty refundInfo;

    @ApiModelProperty(value = "退款时间")
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refundDate;
}
